package com.dabbo.starship.container;
import java.rmi.RemoteException;

import com.dabbo.starship.block.*;
import com.dabbo.starship.cell.CellDoor;
import com.dabbo.starship.interfaces.Block;
import com.dabbo.starship.interfaces.ItemInterface;
import com.dabbo.starship.item.ItemCargoWood;
import com.dabbo.starship.shared.CellLocation;

public class ContainerShip extends ContainerBase {

	private static final long serialVersionUID = 4190317303455409460L;
		
	public ContainerShip(String assetName) throws RemoteException {
		super(assetName);
		
		hullPoints = 100;
		shieldPoints = 0;
		thrust = 0;
		speed = 0;

		// Test Layout		(B)ridge
		//      B			(C)orridor
		//      C			(E)ngine Room
		//     CCC			(R)eactor Room
		//     ERE
		
		// Room objects:
		Block newBridge = new BlockBridge(this);
		Block newCorridor1 = new BlockCargoBay(this);
		Block newCorridor2 = new BlockCorridorES(this);
		Block newCorridor3 = new BlockCorridorWS(this);
		Block newCorridor4 = new BlockDefault(this);
		Block newEngine1 = new BlockEngine(this);
		Block newEngine2 = new BlockEngine(this);
		Block newReactor = new BlockReactor(this);

		ItemInterface item = new ItemCargoWood(); 
		newCorridor1.getCell(new CellLocation(4,4)).addItem(item);
		
		// Doorways:
		newBridge.setCell(new CellDoor(newBridge), new CellLocation(8,4));
		newBridge.getCell(new CellLocation(8,4)).setExit(newBridge, new CellLocation(8,4), newCorridor1, new CellLocation(0,4), true);

		newCorridor1.setCell(new CellDoor(newCorridor1), new CellLocation(8,4));
		newCorridor1.getCell(new CellLocation(8,4)).setExit(newCorridor1, new CellLocation(8,4), newReactor, new CellLocation(0,4), true);
		newCorridor1.setCell(new CellDoor(newCorridor1), new CellLocation(4,0));
		newCorridor1.getCell(new CellLocation(4,0)).setExit(newCorridor1, new CellLocation(4,0), newCorridor2, new CellLocation(4,8), true);
		newCorridor1.setCell(new CellDoor(newCorridor1), new CellLocation(4,8));
		newCorridor1.getCell(new CellLocation(4,8)).setExit(newCorridor1, new CellLocation(4,8), newCorridor3, new CellLocation(4,0), true);

		newCorridor2.setCell(new CellDoor(newCorridor2), new CellLocation(8,4));
		newCorridor2.getCell(new CellLocation(8,4)).setExit(newCorridor2, new CellLocation(8,4), newEngine1, new CellLocation(0,4), true);

		newCorridor3.setCell(new CellDoor(newCorridor3), new CellLocation(8,4));
		newCorridor3.getCell(new CellLocation(8,4)).setExit(newCorridor3, new CellLocation(8,4), newEngine2, new CellLocation(0,4), true);

		// Store in HashMap array:
		blocks.put(newBridge.hashCode(), newBridge);
		blocks.put(newCorridor1.hashCode(), newCorridor1);
		blocks.put(newCorridor2.hashCode(), newCorridor2);
		blocks.put(newCorridor3.hashCode(), newCorridor3);
		blocks.put(newCorridor4.hashCode(), newCorridor4);
		blocks.put(newEngine1.hashCode(), newEngine1);
		blocks.put(newEngine2.hashCode(), newEngine2);
		blocks.put(newReactor.hashCode(), newReactor);
		
		entryBlock = newBridge.hashCode();
	}
	
}
